﻿using PLCTest.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PLCTest.BO
{
    public class WeightTestPlcActionBO
    {

        /// <summary>
        /// 设备号
        /// </summary>
        public string? EquipmentCode { get; set; }

        /// <summary>
        /// 任务号
        /// </summary>
        public int TaskCode { get; set; }

        /// <summary>
        /// 目标位置设备号
        /// </summary>
        public string? ToEquipmentCode { get; set; }

        /// <summary>
        /// 托盘条码
        /// </summary>
        public string? PalletBarcode { get; set; }

        /// <summary>
        /// 产品类型
        /// </summary>
        public short ProductType { get; set; }

        /// <summary>
        /// 握手类型
        /// </summary>
        public short ActionType { get; set; }

        /// <summary>
        /// 任务类型
        /// </summary>
        public short TaskType { get; set; }

        /// <summary>
        /// AGV交互
        /// </summary>
        public short AgvType { get; set; }

        /// <summary>
        /// 重量
        /// </summary>
        public short WeightInfo { get; set; }

        /// <summary>
        /// 预留
        /// </summary>
        public short Reserve { get; set; }

        public void Serialize(byte[] bytes)
        {

            int lengthCode = HelperByte.GetSIntAt(bytes, 1);
            EquipmentCode = HelperByte.GetCharsAt(bytes, 2, lengthCode);
            TaskCode = HelperByte.GetDIntAt(bytes, 6);
            int lengthToCode = HelperByte.GetSIntAt(bytes, 11);
            ToEquipmentCode = HelperByte.GetCharsAt(bytes, 12,lengthToCode);
            int length = HelperByte.GetSIntAt(bytes, 18);
            PalletBarcode = HelperByte.GetCharsAt(bytes, 19, length);
            ProductType = HelperByte.GetByteAt(bytes, 24);
            ActionType = HelperByte.GetIntAt(bytes, 26);
            TaskType = HelperByte.GetByteAt(bytes, 28);
            AgvType = HelperByte.GetByteAt(bytes, 30);
            WeightInfo = HelperByte.GetByteAt(bytes, 32);
            Reserve = HelperByte.GetByteAt(bytes, 34);

        }

    }
}
